package compiler.terminals;

import compiler.HowlToken;
import compiler.HowlType;
import compiler.TokenReader;
import compiler.exceptions.HowlParserException;

/**
 * Class to represent numbers.
 * 
 * @author Sarah Mount <s.mount@wlv.ac.uk>
 * @version 16 Dec 2009
 * 
 * @see compiler.nonterminals.InsertStmt
 * @see compiler.terminals.Geolocation
 * @see compiler.terminals.DataValue
 */
public class Number extends HowlToken {

	private Double number;

	public Number(TokenReader tokenReader) {
		super(tokenReader);
	}

	@Override
	public String codeGenerate() {
		return this.toString();
	}

	@Override
	public HowlToken parse() throws HowlParserException {
		try {
			this.number = Double.valueOf(this.tokenReader.consumeToken());
			return this;
		} catch (Exception e) {
			throw new HowlParserException(this.tokenReader.getStatement(),
					this.tokenReader.getCharNo());
		}
	}

	@Override
	public String toString() {
		return this.number.toString();
	}
	
	public double doubleValue() {
		return this.number.doubleValue();
	}


}